package com.example.seckill.mapper;

import com.example.seckill.entity.TSeckillGoods;
import com.example.seckill.entity.TSeckillOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author vicente
 * @since 2021-08-10
 */
public interface TSeckillOrderMapper extends BaseMapper<TSeckillOrder> {

    @Select("SELECT * from t_seckill_goods " +
            "where (select count(1) from t_seckill_order where user_id = #{userId} and seckill_goods_id = #{goodsId}) = 0 " +
            "and id = #{goodsId}")
    TSeckillGoods userBought(Long userId, Long goodsId);
}
